import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select


driver=webdriver.Firefox()
driver.get('https://www.jiuxian.com/')
driver.maximize_window()
time.sleep(3)

#点击请登录
driver.find_element(By.CLASS_NAME,'headerLogin').click()
time.sleep(3)
#输入账号
driver.find_element(By.NAME,'uname').send_keys('13381144084')
time.sleep(3)
#输入密码
driver.find_element(By.ID,'password').send_keys('grq200566++')
time.sleep(15)
#点击登录按钮
driver.find_element(By.CSS_SELECTOR,'#save').click()
time.sleep(3)
#切换窗口
driver.switch_to.window(driver.window_handles[-1])
time.sleep(4)
#进入我的酒仙
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/ul/li[1]/div[1]/a').click()
time.sleep(5)
#切换窗口
driver.switch_to.window(driver.window_handles[-1])
time.sleep(4)
#断言
dy=driver.find_element(By.XPATH,'/html/body/div[4]/div[2]/div[3]/div[1]/div[1]/span')
print(dy)
#滚动
driver.execute_script('window.scrollTo(0,1000)')
time.sleep(3)

#点击我的收获地址、
driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span').click()
time.sleep(4)
#填写收获人
driver.find_element(By.ID,'people').send_keys('郭瑞淇')
time.sleep(3)
#下拉框
province=Select(driver.find_element(By.ID,'province'))
province.select_by_index(1)
time.sleep(3)

city=Select(driver.find_element(By.ID,'city'))
city.select_by_value('52')
time.sleep(3)

district=Select(driver.find_element(By.ID,'district'))
district.select_by_visible_text('昌平区')
time.sleep(3)



# #搜索框
# driver.find_element(By.XPATH,'//input[contains(@class,"search-form")]').send_keys('茅台')
# time.sleep(3)
# #点击搜索
# driver.find_element(By.XPATH,'//input[@class="search-btn"]').click()
# time.sleep(3)







# #点击五粮液超链接文本
# driver.find_element(By.XPATH,'/html/body/div[4]/div/div[2]/div[2]/p/a[2]').click()
# time.sleep(3)
# #切换窗口
# driver.switch_to.window(driver.window_handles[-1])
# time.sleep(3)
# #点击商品进入商品详情页面
# driver.find_element(By.XPATH,'/html/body/div[6]/div/div[2]/div[6]/ul/li[1]/div[2]/div[1]/a/img').click()
# time.sleep(5)

# #清楚数量
# xg=driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[6]/div[5]/div[2]/div[1]/input')
# xg.clear()
# time.sleep(3)
# #更改数据
# xg.send_keys('3')
# time.sleep(5)

# #收藏
# driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[3]/div[2]/div[1]/a/i').click()
# time.sleep(3)